<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#datagrid-stock-inout')}">
        <fieldset>
            <legend style="font-weight:normal;">页头搜索：</legend>
            <div style="margin:0; padding:1px 5px 5px;">
                <span>成品材料编号：</span>
                <input type="text" name="product_no" class="form-control" size="15">

                <span>产品名称：</span>
                <input type="text" name="product_name" class="form-control" size="15">

                <span>产品分类：</span>
                <select data-toggle="selectpicker" name="category_id">
                    <option value="">全部</option>
                    {!! $optionHtml !!}
                </select>

                <span>流水类型：</span>
                <select data-toggle="selectpicker" name="stock_type">
                    <option value="">全部</option>
                    @foreach($stockType as $key => $val)
                        <option value="{{$key}}">{{$val}}</option>
                    @endforeach
                </select>

                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">开始搜索！</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered" id="datagrid-stock-inout" data-toggle="datagrid" data-options="{
        height: '100%',
        gridTitle : '出入库流水',
        {{--editMode: 'dialog',--}}
            local: 'remote',
            dataUrl: '/admin/stock/list',
            editUrl: '/admin/stock/save-pro',
            delUrl: '/admin/stock/del-pro',
            delPK: 'id',
            linenumberAll: true,
            sortAll: false,
            contextMenuH: true,
            contextMenuB: true,
            inlineEditMult: false,
            paging: {showPagenum:10, selectPageSize:'20,50,100', pageCurrent:1, pageSize:20},
            showEditbtnscol: false,
            customEditbtns: {width:200,position:'replace'},
            fullGrid: true,
            fieldSortable: false,
            filterThead: false,
            columnMenu: false,
        }">
        <thead>
        <tr>
            <th data-options="{name:'product_name',align:'center',width:100}">产品名称</th>
            <th data-options="{name:'product_no',align:'center',width:100}">产品编号</th>
            <th data-options="{name:'water_no',align:'center',width:100}">流水号</th>
            <th data-options="{name:'type', type:'select', items:[{1:'入库'},{2:'出库'}], align:'center',width:100}">类型</th>
            <th data-options="{name:'stock_type', type:'select', items:datagrid_stocktype, align:'center',width:100}">具体类型</th>
            <th data-options="{name:'number',align:'center',width:100}">数量</th>
            <th data-options="{render:stock_water_manage,align:'center'}">操作列</th>
        </tr>
        </thead>
    </table>
</div>
<script>
    function datagrid_stocktype(){
        return [{!! $stockTypeJson !!}]
    }

    function stock_water_manage(value, data){
        var html = '';
        if(data.relate_type == 3){
            html += '<button type="button" class="btn-green" data-toggle="dialog" data-options="{id:\'stock-water-info-dialog\',fresh:true, url:\'/admin/stock/info\', title:\'材料添加详情\',width:600,height:600, data:{id:' + data.relate_id + '}}">查看</button>';
        }
        html += '<button type="button" class="btn-green" data-toggle="edit.datagrid.tr">编辑</button>';
        html += '<button type="button" class="btn-red" data-toggle="del.datagrid.tr">删除</button>';
        return html;
    }
</script>